﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Ruction.Mapping;
using Ruction;

namespace MapGeneratorTest
{
	public partial class FormMain : Form
	{
		public FormMain()
		{
			InitializeComponent();
		}

		private void _buttonTestMapGen_Click(object sender, EventArgs e)
		{
			//Map map = new Map(Constants.XDIM1024x768, Constants.YDIM1024x768);
			//map.NotifyProgress += new NotifyProgressEventHandler(Map_NotifyProgress);

			// Test values discerned from Land.frm
			//Constants.NumPlayers = 2;
			//Constants.LandPct = 0.75;
			//Constants.CFGCountrySize = 6;
			//Constants.PropPct = Constants.MAX_PROP_PCT / 4;
			//Constants.MinLakeSize = 5;
			//Constants.ShapePct = 0.5;
			//Constants.CFGIslands = 2;
			//Constants.CoastPctKeep = 0.99;
			//Constants.IslePctKeep = 0.01;
			//Constants.MaxCountrySize = (Constants.MAX_COUNTRY_SIZE + Constants.MIN_COUNTRY_SIZE) / 2;
			//Constants.CFGNumCountries = Convert.ToInt32(map.XSize * map.YSize * Constants.LandPct);

			//if (Constants.CFGNumCountries < 1) Constants.CFGNumCountries = 1;
			//else if (Constants.CFGNumCountries >= 999) Constants.CFGNumCountries = 998;

			//if ((Constants.CFGNumCountries / Constants.NumPlayers) != (Constants.CFGNumCountries / Constants.NumPlayers))
			//    Constants.CFGNumCountries = (Constants.CFGNumCountries + (Constants.NumPlayers - (Constants.CFGNumCountries % Constants.NumPlayers)));

			// Actual values captured from Map::CreateMap
			Constants.CFGNumCountries = 138;
			Constants.MaxCountrySize = 60;
			Constants.MinLakeSize = 0;
			Constants.LandPct = 0.9;
			Constants.PropPct = 0.35;
			Constants.ShapePct = 0.5;
			Constants.CoastPctKeep = 0;
			Constants.IslePctKeep = 0;
			Constants.CFGIslands = 3;
			Constants.CFGCountrySize = 2;

			Map map = new Map();
			map.SetDimensions(Constants.XDIM1024x768, Constants.YDIM1024x768);
			map.CreateMap(Constants.CFGNumCountries, Constants.MaxCountrySize, Constants.MinLakeSize, Constants.LandPct,
				Constants.PropPct, Constants.ShapePct, Constants.CoastPctKeep, Constants.IslePctKeep);
		}

		void Map_NotifyProgress(string message, bool append)
		{
			if (append) { _labelNotify.Text += message; }
			else { _labelNotify.Text = message; }

			_labelNotify.Update();
		}
	}
}
